package com.jgp.security.controller;

import com.jgp.common.pojo.TreeBean;
import com.jgp.common.utils.JGPUtil;
import com.jgp.security.config.SecUserAdapter;
import com.jgp.sys.controller.JGPBackController;
import com.jgp.sys.utils.TreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 项目   jgp-cloud-parent
 * 作者   loufei
 * 时间   2019-11-03
 */
@CrossOrigin
@RestController
@RequestMapping("/security/menu-api-ctl")
public class SecMenuApiController extends JGPBackController {
    
    @Autowired
    private SecUserAdapter userAdapter;
    
    @RequestMapping("query-tree")
    public List<TreeBean> queryTreeLazy(){
        System.out.println(JGPUtil.toJson(userAdapter.currentUser()));
        return TreeUtil.createTree(userAdapter.currentUser().getMenus());
    }
}
